import { request } from '../utils/request';
import type { ApiResponse, PageResponse } from '../types/common';
import type { Report, ReportFormData, ReportQuery } from '../types/report';

export const reportApi = {
  // 获取报告列表
  getReports: async (params: ReportQuery) => {
    const response = await request.get<ApiResponse<PageResponse<Report>>>('/api/reports', { params });
    return (response as unknown) as ApiResponse<PageResponse<Report>>;
  },

  // 获取报告详情
  getReport: async (id: string) => {
    const response = await request.get<ApiResponse<Report>>(`/api/reports/${id}`);
    return (response as unknown) as ApiResponse<Report>;
  },

  // 创建报告
  createReport: async (data: ReportFormData) => {
    const response = await request.post<ApiResponse<Report>>('/api/reports', data);
    return (response as unknown) as ApiResponse<Report>;
  },

  // 更新报告
  updateReport: async (id: string, data: ReportFormData) => {
    const response = await request.put<ApiResponse<Report>>(`/api/reports/${id}`, data);
    return (response as unknown) as ApiResponse<Report>;
  },

  // 删除报告
  deleteReport: async (id: string) => {
    const response = await request.delete<ApiResponse<void>>(`/api/reports/${id}`);
    return (response as unknown) as ApiResponse<void>;
  },
}; 